package ms.maplestory.boot.client.character.quest.progress;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.client.character.Char;
import ms.maplestory.boot.loaders.DatSerializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

@Getter
@Setter
@Entity
@DiscriminatorValue("level")
public class QuestProgressLevelRequirement extends QuestProgressRequirement {

    @Column(name = "requiredCount")
    private int level;

    public QuestProgressLevelRequirement() {
    }

    public QuestProgressLevelRequirement(int level) {
        this.level = level;
    }

    @Override
    public void write(DataOutputStream dos) throws IOException {
        dos.writeInt(getLevel());
    }

    @Override
    public DatSerializable load(DataInputStream dis) throws IOException {
        return new QuestProgressLevelRequirement(dis.readInt());
    }

    @Override
    public boolean isComplete(Char chr) {
        return false;
    }

    @Override
    public QuestProgressRequirement deepCopy() {
        QuestProgressLevelRequirement questProgressLevelRequirement = new QuestProgressLevelRequirement();
        questProgressLevelRequirement.setLevel(getLevel());
        questProgressLevelRequirement.setOrder(getOrder());
        return questProgressLevelRequirement;
    }

}
